﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom;
using System.Xml.Linq;

namespace CodeDomHelper.CodeDom
{

    [Serializable()]
    public class Clist : CDocList
    {

        public Clist()
            : this("")
        {

        }

        public Clist(string type)
            : base("list")
        {
            Type = type;
        }

        /// <summary>
        /// <list type="">
        /// 
        /// </list>
        /// Initializes a new instance of the <see cref="Clist"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="comment">The comment.</param>
        public Clist(string type, CDocList comment)
            : base("list", comment)
        {
            Type = type;
        }

        public string Type { get; protected set; }
        

        internal override bool Unique { get { return false; } }

        internal override string Serialize
        {
            get
            {
                string p = string.Format(ParamConst, "type", Type);

                StringBuilder s = new StringBuilder();
                s.AppendLine(string.Format(BaliseStartWith1ParamConst, Balise, p));

                s.AppendLine(Value);

                foreach (CDoc a in Nodes)
                    s.AppendLine(a.Serialize);

                s.AppendLine(BaliseEnd);

                return s.ToString();
            }

        }
    }


}
